<template>
  <div class="banner">
    <home-page></home-page>
    <banner :imgs="banners"></banner>
    <div class="recommend">
      <list-title>推荐歌单</list-title>
      <router-link to="/catlist" class="right">更多</router-link>
      <loading v-if="recommendSongs.length == 0"></loading>
      <ul class="imglist" v-else>
        <img-item
          v-for="song in recommendSongs"
          :key="song.id"
          :song="song"
          path="/playlist"
        ></img-item>
      </ul>
      <list-title>最近新歌</list-title>
      <loading v-if="recommendSongs.length == 0"></loading>
      <music-list
        @play="$emit('play', $event)"
        :songlist="newsSong"
        v-else
      ></music-list>
    </div>
  </div>
</template>

<script>
import HomePage from "@/components/HomePage";
import ListTitle from "@/components/ListTitle";
import ImgItem from "@/components/ImgItem";
import Loading from "@/components/Loading";
import Banner from "@/components/Banner";
import MusicList from "@/components/MusicList.vue";
export default {
  name: "Recommend",
  data() {
    return {
      recommendSongs: [],
      result: [],
      page: 1,
      limit: 20,
      isloading: false,
      isMore: true,
      banners: [],
      newsSong: [],
    };
  },
  created() {
    this.axios.get("/banner?type=1").then((result) => {
      this.banners = result.banners;
    });
    this.axios.get("/personalized/newsong?limit=10").then((result) => {
      this.newsSong = result;
    });
    this.$axios.get("/personalized?limit=8").then((result) => {
      this.recommendSongs = result;
    });
  },
  components: {
    HomePage,
    ImgItem,
    ListTitle,
    Loading,
    Banner,
    MusicList,
  },
};
</script>
<style lang="less" scoped>
.recommend {
  position: relative;
  padding-bottom: 60px;
  .right {
    position: absolute;
    right: 10px;
    top: 0px;
    color: #888;
  }
  .imglist {
    display: flex;
    overflow: auto;
    width: 100%;
    height: 220px;
    // padding: 10px 0;
    // margin: 10px 0;
  }
}
</style>
